<template>
	<view class="content">
		<!-- #ifdef H5 || APP-PLUS -->
		<view class="message-title">
			<!-- <commonTitle title="消息中心"></commonTitle> -->
			<view class="title-box">
				<image src="../../../static/common/goback.png" class="goback" @tap="gobackPage"></image>
				<view class="title-text">消息中心</view>
			</view>
		</view>
		<!-- #endif -->
		<view class="list-scroll-content">
			<!-- <ygc-refresh
				@onRefresh="refreshList()" 
				@scrolltolower="addList()"
				:pullupLoadingType="loadingType"> -->
				
				<!-- 公告列表 -->
				<view v-if="articleList.length>0" style="width: 100%;">
					<view class="message-item"
						v-for="(msg,index) in articleList" :key="index"
						@tap="goMessageDetail(msg.articleId)"
					>
						<image src="../../../static/common/message-icon.png" class="message-icon"></image>
						<view class="message-detail">
							<view class="msg-detail-title">
								<view class="big-title">公告</view>
								<view class="small-title">{{msg.title}}</view>
							</view>
							<view class="message-time">
								<view class="msg-time">{{getMsgDate(msg.publishTime)}}</view>
								<image src="../../../static/common/unread-msg.png" class="un-readMsg"></image>
							</view>
						</view>
					</view>
				</view>
				<view v-else style="width: 100%; display: flex;flex-direction: column;justify-content: center;align-items: center;">
					<image src="../../../static/common/nodata-sub.png" style="width: 160upx;height: 160upx;margin: 100upx 0;"></image>
				</view>
			<!-- </ygc-refresh> -->
		</view>
		
	</view>
</template>

<script>
	import commonTitle from'../../../components/titile/title.vue'
	// import ygcRefresh from '../../../components/ygc-refresh/ygc-refresh.vue';
	export default{
		components:{
			commonTitle,
			// ygcRefresh
		},
		data () {
			return {
				loadingType: 'more',
				newArticle:"",
				articleList:[],
				apptoken:""
			}
		},
		onLoad() {
			this.apptoken = uni.getStorageSync('apptoken');
			this.getnewArticle();
		},
		methods: {
			gobackPage(){
				uni.navigateBack({
					delta:1,
					animationType:'slide-out-right'
				})
			},
			getMsgDate(time){
				//publishTime
				if(time.indexOf('-')==-1){
					return	this.$CommonJS.getTime(time);
				}else{
					return time.split(' ')[0];
				}
				
			},
			getnewArticle(){
				const _this = this;
				//公告列表
				uni.request({
					url:this.$API.URL + this.$API.notice_list,
					data:{apptoken:this.apptoken},
					success(res) {
						_this.articleList = res.data.data;
						console.log(res)
					},
					fail(res){
						console.log(res)
					}
				})
			},
			/**
			 * 下拉刷新
			 */
			// refreshList () {
			//   console.log('下拉刷新');
			// },
			/**
			 * 上拉加载
			 */
			// addList() {
			// 	console.log('上拉加载');
			// 	this.loadingType = 'loading';
			// 	setTimeout(() => {
			// 		this.loadingType = 'more';
			// 	}, 500);
				
			// },
			//公告详情
			goMessageDetail(id){
				this.$CommonJS.navigateTo('./sub-message?articleId='+id)
			}
			
		}
		
	}
</script>

<style>
	
	@import url("sub-message.css");
</style>
